#pragma once

#include <linuxboot/types.h>

typedef struct __part_dev part_dev_t;
typedef struct __part part_t;

struct __part_dev
{
    uint32_t init;
    uint32_t id;
    void *blkdev;
    void *init_dev;
    int (*read)(part_dev_t *dev, uint64_t src, void *dst, int size, unsigned int part_id);
    void *write;
};
struct __part
{
    uint32_t start_sect;
    uint32_t nr_sects;
    uint32_t part_attr;
    uint32_t part_id;
    const char *name;
    void *info;
};

#define BOOTIMG_OFFSET 2 // in blocks

static void (*video_printf)(const char *fmt, ...) = (void *)(0x46032DAC | 1);
static void (*dprintf)(const char *fmt, ...) = (void *)(0x460333B8 | 1);
static part_dev_t *(*mt_part_get_device)() = (void *)(0x46053740 | 1);
static part_t *(*mt_part_get_partition)(const char *name) = (void *)(0x46004C30 | 1);
static void (*arch_clean_invalidate_cache_range)(uint32_t start, uint32_t size) = (void *)(0x4601C5A0);
static void (*bldr_load_dtb)(const char *n) = (void *)(0x460276E8 | 1);

static void (*mt_boot_init)(void) = (void *)(0x4602A1C0 | 1);
static void (*mdelay)(uint32_t n) = (void*)(0x460050CC | 1);
static void (*udelay)(uint32_t n) = (void*)(0x460050D0 | 1);
static uint32_t (*get_devinfo_with_index)(uint32_t i) = (void*)(0x4605BF48 | 1);